********************************************************************************
* Table 1
********************************************************************************
clear all
set more off

use "$data/fiscal.dta", clear

replace emp=0 if emp==.
gen lf=1 if unemp!=.
gen male=1 if sex==0
replace male=0 if male==.

global vars male age sch emp unemp selfemp mthly_inc_real below_minwage

matrix A = J(8,3,.)
local i = 1
foreach x of global vars{ 
	qui reg `x' [pw=fex12] if group==1 & year == 2013
	matrix A[`i',1] = _b[_cons]
	qui reg `x' [pw=fex12] if group==2 & year == 2013
	matrix A[`i',2] = _b[_cons]
	qui reg `x' [pw=fex12] if group==3 & year == 2013
	matrix A[`i',3] = _b[_cons]
	local i = `i' + 1
}
*

matrix B = J(8,3,.)
local i = 1
foreach x of global vars{ 
	qui reg `x' [pw=fex12] if group==1 & year == 2018
	matrix B[`i',1] = _b[_cons]
	qui reg `x' [pw=fex12] if group==2 & year == 2018
	matrix B[`i',2] = _b[_cons]
	qui reg `x' [pw=fex12] if group==3 & year == 2018
	matrix B[`i',3] = _b[_cons]
	local i = `i' + 1
}
*
*

#delimit ;

matrix C = (100,0,0,0,0,0,0,0\
			0,1,0,0,0,0,0,0\
			0,0,1,0,0,0,0,0\
			0,0,0,100,0,0,0,0\
			0,0,0,0,100,0,0,0\
			0,0,0,0,0,100,0,0\
			0,0,0,0,0,0,0.001,0\
			0,0,0,0,0,0,0,100);

matrix D = C * A;
matrix E = C * B;

frmttable , statmat(D) sdec(1)
title("Descriptive Statistics for the Native and Immigrant Population, 2013")
ctitle("Characteristics","Natives","Returnees","Venezuelan-born")
rtitle("2. Percent male"\"3. Avg. age"\"4. Avg. education (years)"\
"6. Employment rate"\"7. Unemployment rate"\"8. Percent self-employed"\
"9. Avg. monthly real wage (k)"\"10. Percent earning below min. wage");

frmttable , statmat(E) sdec(1)
title("Descriptive Statistics for the Native and Immigrant Population, 2018")
ctitle("Characteristics","Natives","Returnees","Venezuelan-born")
rtitle("2. Percent male"\"3. Avg. age"\"4. Avg. education (years)"\
"6. Employment rate"\"7. Unemployment rate"\"8. Percent self-employed"\
"9. Avg. monthly real wage (k)"\"10. Percent earning below min. wage");
#delimit cr

*info to estimate share of the population
tab year group [iw = fex12], row nofreq

*info to estimate share of the labor force
tab year group [iw = fex12] if lf==1, row nofreq


